/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bean.chart.editors;

import java.beans.PropertyEditorManager;
import java.beans.PropertyEditorSupport;
import java.util.Arrays;

/**
 *
 * @author Lukasz
 */
public class ChartLegendPositionEditor extends PropertyEditorSupport{
    
    private String[] tags = {"Left", "Up", "Right", "Down"};
    
    @Override
    public String[] getTags(){
       return tags;
    }
     @Override
    public void setAsText(String text) {
        int index = Arrays.asList(tags).indexOf(text);
        if(index>=0) setValue(ChartLegendPosition.values()[index]);
    }

    @Override
    public String getAsText() {
        int index = ((ChartLegendPosition)getValue()).ordinal();
        return tags[index];
    }
    

    @Override
    public String getJavaInitializationString() {
        return ChartLegendPosition.class.getName()+"." +getValue();
    }
}
